<?php
declare(strict_types=1);

namespace app\api\model;

use app\common\model\PaymentLog as PaymentLogModel;
use cores\exception\BaseException;

class PaymentLog extends PaymentLogModel
{


    /**
     * 支付记录
     * @param int $storeId
     * @param string $orderNo
     * @param string $payPrice
     * @param string $listener
     * @param array $extra ['business' => '业务来源表','expire_time' => '失效时间']
     * @throws BaseException
     */
    public function paymentRecord(int $storeId, string $orderNo, string $payPrice, string $listener, array $extra = [])
    {
        self::create([
            'store_id'    => $storeId,
            'user_id'     => \app\api\service\User::getCurrentLoginUserId(),
            'order_no'    => $orderNo,
            'pay_price'   => $payPrice,
            'handle'      => $listener,
            'business'    => $extra['business'] ?? '',
            'expire_time' => $extra['expire_time'] ?? time() + 1800
        ]);
    }
}